<html>
<head>
<title>EPK.</title>
<!--javascript: -->

<script type="text/javascript"> 
function tratardata_f(eguna,hilea,urtea){
	//document.location="?eguna="+eguna+"&hilea="+hilea+"&urtea="+urtea;
  document.getElementById("hasieradata").value=urtea+"/"+hilea+"/"+eguna;
}
	
	function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frahilea.length) {
    d=parent.frahilea[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
</script>
<style>
.m1 {
   font-family:MS Sans Serif;
   font-size:8pt
}

a {
   text-decoration:none;
   color:#000000;
}
</style>
</head>
<body bgcolor="424a6e">

<? 	$pasa_bai=false;
	$bat=$_COOKIE["bat"];
	$bi=$_COOKIE["bi"];
	

			if (!$konexioa=mysql_connect('localhost')) {
   				die('Ez da konektatu : ' . mysql_error());
			}// if konexioa
			if (!mysql_select_db("users")){
   				die("Ez da datu-basea existitzen - oO!");
			}//if select_db
			$sql_gald="SELECT * FROM erabiltzaileak WHERE izena='$bat' && pasahitza='$bi'";
			$pito= mysql_query($sql_gald) or die(mysql_error());
			if ($kaka=mysql_fetch_array($pito))
			{//emaitza dau
				$pasa_bai=true;
			}
		
      	if(!$pasa_bai){?>
        <div align="center"><font color="#FFFFFF"><h3>Ez daukazu baimenik hemen egoteko</h3></font></div>
		<? 
		}else{ 
$erabiltzailea=$_POST['erabiltzailea'];
$hilabetea=$_POST['hilabetea'];
$urtea=$_POST['urtea'];
?>


<form><table border="0" cellpadding="5" cellspacing="0" bgcolor="#D4D0C8">
  <tr>
    <td width="100%">
<?
$fecha = getdate(time());
$dia = 30;
$mes = $_POST["hilabetea"];
$ano = $_POST["urtea"];
$fecha = mktime(0,0,0,$mes,$dia,$ano);
$fechaInicioMes = mktime(0,0,0,$mes,1,$ano);
$fechaInicioMes = date("w",$fechaInicioMes); 
?>
<br>
    <font size="1">&nbsp;</font><table border="1" cellpadding="2" cellspacing="0" width="850" class="m1" bgcolor="#FFFFFF" height="800">
<?

 if (!mysql_select_db("planak")){
   				die("Ez da datu-basea existitzen - oO!");
}//if select_db

$diasSem = Array ('ASTELEHENA','ASTEARTEA','ASTEAZKENA','OSTEGUNA','OSTIRALA','LARUNBATA','IGANDEA');
$ultimoDia = date('t',$fecha);
$numMes = 0;
for ($fila = 0; $fila < 7; $fila++){
  echo "      <tr>\n";
  for ($coln = 0; $coln < 7; $coln++){
    $posicion = Array (1,2,3,4,5,6,0);
    echo '        <td width="100" height="100"';
    if($fila == 0)echo ' bgcolor="#808080"';
    //if($dia-1 == $numMes)echo ' bgcolor="#0A246A"';
    echo " align=\"center\">\n";
    echo '        ';
    if($fila == 0)echo '<font color="#D4D0C8"><b>'.$diasSem[$coln].'</b>';
    elseif(($numMes && $numMes < $ultimoDia) || (!$numMes && $posicion[$coln] == $fechaInicioMes)){
	  ++$numMes;
	 // if($dia == $numMes)echo '<font color="#FFFFFF">';
	  ?><table align="left" class="m1" bgcolor="#FFFFFF"><tr><td><?
	  echo "<font color=\"#0000CC\">".($numMes)."</font></td></tr><tr><td>";
			  
			  $sql_gald="SELECT DISTINCT planid, COUNT(*) FROM plan WHERE erab='$erabiltzailea' && hilabetea='$hilabetea' && urtea='$urtea' && eguna='$numMes' GROUP BY planid";
			  $pito= mysql_query($sql_gald) or die(mysql_error());
			  if ($kaka=mysql_fetch_array($pito)){
			  	echo "ID: </td></tr><tr><td>".$kaka[0]."</td></tr><tr><td>Ariketa kop: ".$kaka[1]."</td></tr><tr><td><a href=\"javascript:void(0)\" onClick=\"window.open('plana_bistaratu3.php?plana=".$kaka[0]."', 'Plana_bistaratu', 'scrollbars=1, width=760 , height=400');\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('ikusi".$kaka[0]."','','images/ikusi2.jpg',1)\"><img src=\"images/ikusi1.jpg\" border=\"0\" id=\"ikusi".$kaka[0]."\"></a>";}
			 /* while ($kaka=mysql_fetch_array($pito))
			  {//emaitza dau
				$planid=$kaka[0];
				$sql_gald2="SELECT * FROM plan WHERE planid='$planid'";
				$pito2= mysql_query($sql_gald2) or die(mysql_error());
				while ($kaka2=mysql_fetch_array($pito2))
			  	{
					?>
                        <tr bgcolor="#99CCFF"><td>Ariketa: </td><td><? echo $kaka2[1]; ?></td></tr>
                        <tr bgcolor="#99CCFF"><td>Zona: </td><td><? echo $kaka2[9]; ?></td></tr>
                        <tr bgcolor="#99CCFF"><td>Series: </td><td><? echo $kaka2[2]; ?></td></tr>
                        <tr bgcolor="#99CCFF"><td>Errepikapenak: </td><td><? echo $kaka2[3]; ?></td></tr>
                        <tr bgcolor="#99CCFF"><td>Karga: </td><td><? echo $kaka2[4]; ?></td></tr>
                        <tr bgcolor="#99CCFF"><td>Frekuentzia: </td><td><? echo $kaka2[5]; ?></td></tr>
                        <tr bgcolor="#99CCFF"><td>Atseden: </td><td><? echo $kaka2[6]; ?></td></tr>
                        <tr bgcolor="#99CCFF"><td>Abiadura: </td><td><? echo $kaka2[7]; ?></td></tr>
                        <tr bgcolor="#99CCFF"><td>Max%: </td><td><? echo $kaka2[8]; ?></td></tr>
						<tr bgcolor="#99AAFF"><td><hr></td><td><hr></td></tr>
                    <?
				}
				
			  }//whilea*/
      ?></td></tr></table><?
	}//else if
    echo "</td>\n";
 }//for2
  echo "      </tr>\n";
}//for1
	 




?>
    </table>
    </td>
  </tr>
</table></form>















<?
	  }//else
if($ezdago=='1')
	echo "<div align=\"left\"><font color=\"#FFFFFF\"><h3>Ez dago planik data horretan erabiltzaile horrentzako</h3></font></div>";
?>

</body>
</html>
